home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-04-13 | 2.3 KB | 97 lines | [TEXT/ttxt] |
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- deferred class STD_FILE
- --
- -- Root class of :
- -- - STD_INPUT to read on the keyboard (known as `std_input').
- -- - STD_OUTPUT to write on the screen (known as `std_output').
- -- - STD_INPUT_OUTPUT to read/write on the keyboard/screen (known as `io').
- -- - STD_FILE_READ to read a named file on disk.
- -- - STD_FILE_WRITE to write a named file on disk.
- -- - CURSES interactive screen/cursor handling.
- -- - STD_ERROR to write on the error file (default is screen).
- --
- -- Note : a common list of feature (such as `put_character',
- -- `put_string', etc.) are shared by all classes so you can
- -- exchanges objects.
- -- For example, it easy to test writing on the screen (using
- -- `std_output') and then to use a named file (using
- -- STD_FILE_WRITE or `connect_to').
- --
-
- feature {ANY}
-
- path: STRING;
- -- Not Void when connected to the corresponding file on the disk.
-
- connect_to(new_path: STRING) is
- require
- not is_connected;
- path = Void;
- not new_path.empty;
- deferred
- end;
-
- disconnect is
- require
- is_connected;
- deferred
- end;
-
- is_connected: BOOLEAN is
- do
- Result := path /= Void;
- end;
-
- feature {NONE}
- --
- -- NOTE: use only a few basic external C calls.
- --
-
- mode: STRING;
-
- tmp_path: STRING is
- once
- !!Result.make(256);
- end;
-
- fopen(f: STRING; m: STRING): POINTER is
- require
- f /= Void;
- m /= Void
- do
- --*** MLK : tmp_path.copy(f);
- --*** MLK : Result := ansi_c_fopen(tmp_path.to_external,m.to_external);
- Result := ansi_c_fopen(f.twin.to_external,m.to_external);
- end;
-
- ansi_c_fopen(f: POINTER; m: POINTER): POINTER is
- external "IC"
- alias "fopen"
- end;
-
- fclose(stream_pointer : POINTER): INTEGER is
- external "IC"
- end;
-
- fputc(c: CHARACTER; stream_pointer: POINTER): CHARACTER is
- external "IC"
- end;
-
- fgetc(stream_pointer : POINTER): CHARACTER is
- -- Result is of type CHARACTER because a int is a char !
- external "IC"
- end;
-
- feof(stream_ptr: POINTER): BOOLEAN is
- do
- c_inline_c("R=feof((FILE*)C->_input_stream);");
- end;
-
- fflush(stream_pointer: POINTER): INTEGER is
- external "IC"
- end;
-
- end -- STD_FILE
-